The default render strategy used within the component. More...
Public Member Functions | |
DefaultRenderStrategy () | |
virtual | ~DefaultRenderStrategy () |
const nkMemory::BufferCast< SlotEntry > & | getSlots () const |
bool | getFrustumCull () const |
bool | getOrderQueue () const |
void | setFrustumCull (bool value) |
void | setOrderQueue (bool value) |
virtual RenderCommandQueue | bakeRenderCommandQueue (Shader *shader, bool transparent) override |
virtual void | updateAddRenderSlot (Entity *ent, const EntityRenderInfoSlot *slot) override |
virtual void | updateEraseRenderSlot (Entity *ent, const EntityRenderInfoSlot *slot) override |
![]() | |
RenderStrategy () | |
virtual | ~RenderStrategy () |
The default render strategy used within the component.
The strategy offers, out of the box, a way to render passes with some optimizations.
It will by default frustum cull, reorder, and collapse commands in an attempt to limit their number, and reduce the amount of GPU calls.
It will also use the rendering information by selecting one LOD to render from each slots provided. The selection will happen based on its quality metric (this will be populated once LOD are properly supported).
nkGraphics::DefaultRenderStrategy::DefaultRenderStrategy | ( | ) |
Default constructor.
|
virtual |
Destructor.
const nkMemory::BufferCast<SlotEntry>& nkGraphics::DefaultRenderStrategy::getSlots | ( | ) | const |
bool nkGraphics::DefaultRenderStrategy::getFrustumCull | ( | ) | const |
bool nkGraphics::DefaultRenderStrategy::getOrderQueue | ( | ) | const |
void nkGraphics::DefaultRenderStrategy::setFrustumCull | ( | bool | value | ) |
Sets whether the strategy should frustum cull or not when generating the command queue. Frustum culling adds a check when baking the LODs to render, by checking their bounds against the active camera frustum. If they are not inside, implying they won't color any pixels, then the drawing command won't be issued in the first place. On by default, this can be turned off to reduce load on CPU if required.
value | Whether the culling should happen (true) or not (false). |
void nkGraphics::DefaultRenderStrategy::setOrderQueue | ( | bool | value | ) |
Sets whether the strategy should reorder its commands or not within the command queue. Reordering aims to reduce the number of potential state switching required by the renderer, and improve drawing speed / quality. It will :
- If transparent : - Reorder from back to front to properly handle alpha blending - If not transparent : - If MonoMaterialPass : - Order by Mesh ID first to reduce the number of vertex buffer changes - Order from front to back to try to limit overdraw - If RenderScenePass : - Order by Program ID to reduce the number of PSO switches - Order by Mesh ID to then reduce the number of vertex buffer changes - Order from front to back to try to limit overdraw
Enabling it also allows to further optimize the queue as it will improve the command collapsing results, as similar resources using commands they get packed together. On by default, this can be turned off to reduce load on CPU if required.
value | Whether the reordering should happen (true) or not (false). |
|
overridevirtual |
Generates the final command queue that will be communicated to the active Renderer. This method is called whenever a RenderQueue is rendered, and should return the queue to be executed from it.
shader | A shader, provided by a MonoMaterialPass if it is the caller, nullptr otherwise. |
transparent | Whether the pass has been marked as transparent (true) or not (false). |
Implements nkGraphics::RenderStrategy.
|
overridevirtual |
Called whenever a parent RenderQueue's Entity gets a new slot added to it.
ent | The entity calling. |
slot | The slot newly created. |
Implements nkGraphics::RenderStrategy.
|
overridevirtual |
Called whenever a parent RenderQueue's Entity loses a slot.
ent | The entity calling. |
slot | The slot erased. |
Implements nkGraphics::RenderStrategy.